// Serwery.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <sstream> 
#include "serwery.h"
#include "XmlRpc.h"
#include "RemoteServer.h"
#include "XmlServer.h"
#include "boost\thread.hpp"

using namespace XmlRpc;
const int standartPort = 40009; 

const int standDestPort = 40000;
const std::string stdAdress("127.0.0.1");
const std::string myAddress("127.0.0.1");



int main(int argc, char* argv[])
{
	if (!(argc == 5 || argc == 7)) return 0;
	
	int port;
	std::string serverName;

	int nodePort;
	std::string nodeAddress;
	std::string myAddress;

		serverName = std::string(argv[2]);
		myAddress = std::string(argv[3]);
		port = atoi(argv[4]);
		
	
	ServerInfo serverInfo;
	if(argc == 7)
	{
		nodePort = atoi(argv[6]);
		nodeAddress = std::string(argv[5]);
		serverInfo.address.ip.str = nodeAddress;
		serverInfo.address.socet = nodePort;
	}

	
	Server server(atoi(argv[1]),port,serverName,myAddress);

	
	
	if(argc == 7)
		server.startServer(serverInfo);
	else
		server.startServer();

	std::cout<<port<<std::endl;
	int x;
	std::cin>>x;

	return 0;
}

